hvm: Fix ACPI shutdown, broken by my previous changeset.
authorKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 15:24:50 +0000 (16:24 +0100)
committerKeir Fraser <keir@xensource.com>
Sat, 12 May 2007 15:24:50 +0000 (16:24 +0100)
It turns out that although PIIX4 hardware defines the S5 type code to
be 000, all OSes will discover the correct code by evlauating an \_Sx
object in the ACPI DSDT. And we set the type code in that object to be
111.

So this patch keeps the other cleanups made to the piix4acpi.c file,
but switches back to checking for code 111. It also makes it clearer
in both the ioemu code and in the dsdt source code where these magic
numbers come from.

Let's hope noone actually has the true PIIX4 type codes hardcoded
(it's highly doubtful that anyone would).

Signed-off-by: Keir Fraser <keir@xensource.com>
tools/firmware/hvmloader/acpi/dsdt.asl
tools/firmware/hvmloader/acpi/dsdt.c
tools/ioemu/hw/piix4acpi.c

index 0c843c183334b170f69cea70d4933b64ed040117..1f0a83960c7638685e973ed06dd0ff2fcd9bc5ef 100644 (file)
@@ -27,13 +27,13 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
     Name (\APCL, 0x00010000)
     Name (\PUID, 0x00)
 
-    /* Poweroff support - ties in with qemu emulation */
+    /* S5 (power-off) type codes: must match with piix4 emulation! */
     Name (\_S5, Package (0x04)
     {
-        0x07,
-        0x07,
-        0x00,
-        0x00
+        0x07,  /* PM1a_CNT.SLP_TYP */
+        0x07,  /* PM1b_CNT.SLP_TYP */
+        0x00,  /* reserved */
+        0x00   /* reserved */
     })
 
     Name(PICD, 0)
index d757ed107cd6d9817b397a7eeb7380f128ac59cf..eb8d1da867e83445818d05abf2cf2484c81e5fc7 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * 
  * Intel ACPI Component Architecture
- * ASL Optimizing Compiler version 20060707 [Feb 16 2007]
+ * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
  * Copyright (C) 2000 - 2006 Intel Corporation
  * Supports ACPI Specification Revision 3.0a
  * 
- * Compilation of "dsdt.asl" - Mon Feb 26 11:09:49 2007
+ * Compilation of "dsdt.asl" - Sat May 12 16:13:55 2007
  * 
  * C source code output
  *
index fcaadbf4371d8ff2af5a458cb85f2a37d543372c..e232e820352255d4a0b76462d42e55d54a6f2448 100644 (file)
 
 #include "vl.h"
 
-/* PMCNTRL */
+/* PM1a_CNT bits, as defined in the ACPI specification. */
 #define SCI_EN            (1 <<  0)
 #define GBL_RLS           (1 <<  2)
-#define SUS_TYP           (7 << 10)
-#define SUS_EN            (1 << 13)
+#define SLP_TYP_Sx        (7 << 10)
+#define SLP_EN            (1 << 13)
+
+/* Sleep state type codes as defined by the \_Sx objects in the DSDT. */
+/* These must be kept in sync with the DSDT (hvmloader/acpi/dsdt.asl) */
+#define SLP_TYP_S5        (7 << 10)
 
 typedef struct AcpiDeviceState AcpiDeviceState;
 AcpiDeviceState *acpi_device_table;
@@ -69,7 +73,7 @@ static uint32_t acpiPm1Control_readb(void *opaque, uint32_t addr)
 {
     PCIAcpiState *s = opaque;
     /* Mask out the write-only bits */
-    return (uint8_t)(s->pm1_control & ~(GBL_RLS|SUS_EN));
+    return (uint8_t)(s->pm1_control & ~(GBL_RLS|SLP_EN));
 }
 
 static void acpiPm1ControlP1_writeb(void *opaque, uint32_t addr, uint32_t val)
@@ -77,10 +81,10 @@ static void acpiPm1ControlP1_writeb(void *opaque, uint32_t addr, uint32_t val)
     PCIAcpiState *s = opaque;
 
     val <<= 8;
-    s->pm1_control = ((s->pm1_control & 0xff) | val) & ~SUS_EN;
+    s->pm1_control = ((s->pm1_control & 0xff) | val) & ~SLP_EN;
 
     /* Check for power off request. */
-    if ((val & (SUS_EN|SUS_TYP)) == SUS_EN)
+    if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5))
         qemu_system_shutdown_request();
 }
 
@@ -88,17 +92,17 @@ static uint32_t acpiPm1ControlP1_readb(void *opaque, uint32_t addr)
 {
     PCIAcpiState *s = opaque;
     /* Mask out the write-only bits */
-    return (uint8_t)((s->pm1_control & ~(GBL_RLS|SUS_EN)) >> 8);
+    return (uint8_t)((s->pm1_control & ~(GBL_RLS|SLP_EN)) >> 8);
 }
 
 static void acpiPm1Control_writew(void *opaque, uint32_t addr, uint32_t val)
 {
     PCIAcpiState *s = opaque;
 
-    s->pm1_control = val & ~SUS_EN;
+    s->pm1_control = val & ~SLP_EN;
 
     /* Check for power off request. */
-    if ((val & (SUS_EN|SUS_TYP)) == SUS_EN)
+    if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5))
         qemu_system_shutdown_request();
 }
 
@@ -106,7 +110,7 @@ static uint32_t acpiPm1Control_readw(void *opaque, uint32_t addr)
 {
     PCIAcpiState *s = opaque;
     /* Mask out the write-only bits */
-    return (s->pm1_control & ~(GBL_RLS|SUS_EN));
+    return (s->pm1_control & ~(GBL_RLS|SLP_EN));
 }
 
 static void acpi_map(PCIDevice *pci_dev, int region_num,